//
//  UIBarButtonItem+Extention.swift
//  Weibo
//
//  Created by xiongminghua on 16/7/25.
//  Copyright © 2016年 熊明华. All rights reserved.
//

import UIKit

/// 封装一个分类， 给导航栏添加按钮
extension UIBarButtonItem {
    
    /// 扩展里面只能使用便利构造函数, 方便外界使用
    convenience init(imageName: String) {
        
        let button = UIButton(type: UIButtonType.Custom)
        button.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        button.setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        // 设置图片大小自适应
        button.sizeToFit()
        
        self.init(customView: button)
    }
    
}
